package archer.application.core.entity.system;

import archer.application.core.constant.Constant;
import archer.framework.common.entity.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import java.util.List;

/**
 * 系统菜单
 *
 * @author christ
 * @date 2016/6/7
 */
@Entity
public class Menu extends BaseEntity {

    public static final Find<Menu> find = new Find<Menu>(Menu.class);

    //--------------------------
    //  fields
    //--------------------------
    @Column(columnDefinition = "varchar(32) COMMENT '父级菜单'")
    private String parentId;

    @Column(columnDefinition = "varchar(256) COMMENT '菜单url'")
    private String url;

    @Column(columnDefinition = "varchar(32) COMMENT '菜单名称'")
    private String name;

    @Column(columnDefinition = "varchar(32) COMMENT '菜单排序号'")
    private String sort;

    @Column(columnDefinition = "varchar(256) COMMENT '备注'")
    private String remark;

    @Column(columnDefinition = "varchar(256) COMMENT '菜单css样式'")
    private String cssClass;

    @Column(columnDefinition = "varchar(256) COMMENT '菜单图标'")
    private String iconClass;

    @Column(columnDefinition = "char(1)  default 'Y' COMMENT' 是否显示'")
    protected String display = Constant.EntityDefault.Y;

    //--------------------------
    //  relations
    //--------------------------
    @OneToMany(mappedBy = "menu")
    private List<RoleMenuRel> roleMenuRels;

    //--------------------------
    //  getter setter
    //--------------------------

    @Transient
    private Boolean checked = false;

    public Boolean getChecked() {
        return checked;
    }

    public Menu setChecked(Boolean checked) {
        this.checked = checked;
        return this;
    }

    public String getParentId() {
        return parentId;
    }

    public Menu setParentId(String parentId) {
        this.parentId = parentId;
        return this;
    }

    public String getUrl() {
        return url;
    }

    public Menu setUrl(String url) {
        this.url = url;
        return this;
    }

    public String getName() {
        return name;
    }

    public Menu setName(String name) {
        this.name = name;
        return this;
    }

    public String getSort() {
        return sort;
    }

    public Menu setSort(String sort) {
        this.sort = sort;
        return this;
    }

    public String getRemark() {
        return remark;
    }

    public Menu setRemark(String remark) {
        this.remark = remark;
        return this;
    }

    public List<RoleMenuRel> getRoleMenuRels() {
        return roleMenuRels;
    }

    public Menu setRoleMenuRels(List<RoleMenuRel> roleMenuRels) {
        this.roleMenuRels = roleMenuRels;
        return this;
    }

    public String getCssClass() {
        return cssClass;
    }

    public Menu setCssClass(String cssClass) {
        this.cssClass = cssClass;
        return this;
    }

    public String getIconClass() {
        return iconClass;
    }

    public Menu setIconClass(String iconClass) {
        this.iconClass = iconClass;
        return this;
    }

    public String getDisplay() {
        return display;
    }

    public Menu setDisplay(String display) {
        this.display = display;
        return this;
    }
}
